From 6e5317c25d77e492dc6b46e6dc96e10d231def2f Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Mon, 17 Mar 2014 08:48:09 +0200 Subject: [PATCH] Restore compatibility with legacy comment-start-skip values * lisp/newcomment.el (comment-beginning): If `comment-start-skip' doesn't match, move back one char and try again. --- lisp/ChangeLog | 3 +++ lisp/newcomment.el | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 20a259a129c..9e542255ea9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,8 @@ 2014-03-17 Dmitry Gutov + * newcomment.el (comment-beginning): If `comment-start-skip' + doesn't match, move back one char and try again. (Bug#16971) + * emacs-lisp/lisp-mode.el (lisp-mode-variables): Set `comment-use-syntax' to t to avoid the unnecessary runtime check. Set `comment-start-skip' to a simpler value that doesn't try to diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 710dc74077d..44e270a66ea 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el @@ -523,7 +523,12 @@ the same as `comment-search-backward'." (when (nth 4 state) (goto-char (nth 8 state)) (prog1 (point) - (when (looking-at comment-start-skip) + (when (or (looking-at comment-start-skip) + ;; Some older modes use regexps that check the + ;; char before the comment for quoting. (Bug#16971) + (save-excursion + (forward-char -1) + (looking-at comment-start-skip))) (goto-char (match-end 0)))))) ;; Can't rely on the syntax table, let's guess based on font-lock. (unless (eq (get-text-property (point) 'face) 'font-lock-string-face) -- 2.30.2